<template>
  <div>
    <!-- <p>当前未处理信息件 <span class="c-blue">123456</span> 条</p> -->
    <dg-row v-if="Array.isArray(list) && list.length" zebra="1rem" gutter="1rem">
      <dg-col :span="4" class="work-box" v-for="(item, index) in list" :key="index" @click.native="onRoute(item)">
        <dg-row type="flex" gutter="0.5rem" class="work-item">
          <dg-col :flex="1">
            <p class="work-item__num" :style="`color: rgb(${item.color})`">{{ item.dqs }}/{{ item.sum }}</p>
            <p>{{ item.name }}</p>
          </dg-col>
          <dg-col :width="50">
            <p class="work-item__icon" :style="`color: rgb(${item.color});background: rgba(${item.color}, 0.1)`">
              <i :class="['dg-iconp', item.icon]"></i>
            </p>
          </dg-col>
        </dg-row>
      </dg-col>
    </dg-row>
    <no-record v-else></no-record>
  </div>
</template>

<script>
import { messageCensus } from '@/api/common';

export default {
  name: 'xxtj',
  data() {
    return {
      list: [],
      iconTypes: {
        // 要情信息
        yqxx: {
          icon: 'iconp-f-gongan',
          color: '94,119,254',
          routeName: 'ImpManageHome'
        },
        // 线索信息
        xsxx: {
          icon: 'iconp-f-xinxi',
          color: '246,164,36',
          routeName: 'AllBureausHome'
        },
        // 要情指令
        yqzl: {
          icon: 'iconp-f-wenben',
          color: '105,208,232',
          routeName: 'ImportFeedback'
        },
        // 线索指令
        xszl: {
          icon: 'iconp-f-xiansuo',
          color: '247,190,76',
          routeName: 'ClueSignFeedback'
        },
        // 线索信息(情报)
        xsqb: {
          icon: 'iconp-f-xxiansuo',
          color: '56,146,248 ',
          routeName: 'LocalBureausHome'
        },
        // 公告信息
        ggxx: {
          icon: 'iconp-f-xiaoxi',
          color: '41,204,242',
          routeName: 'NoticeInfomation'
        },
        // 研判任务
        yprw: {
          icon: 'iconp-f-yanpan',
          color: '98,210,144',
          routeName: 'PoliceJudgeTaskHome'
        },
        // 批示信息
        psxx: {
          icon: 'iconp-f-pishi',
          color: '92,158,248',
          routeName: 'SubmitReview'
        },
        // 报警处理
        yylbjcl: {
          icon: 'iconp-f-pishi',
          color: '92,158,248',
          routeName: 'AlarmHandleHome'
        }
      }
    };
  },
  computed: {},
  methods: {
    fetchData() {
      messageCensus()
        .then(res => {
          this.list = res.data.map(ele => {
            const type = this.iconTypes[ele.code];
            return {
              ...ele,
              ...type
            };
          });
        })
        .catch(() => {});
    },
    onRoute(data) {
      this.$router.push({
        name: data.routeName
      });
    }
  },
  created() {
    this.fetchData();
  }
};
</script>

<style scoped lang="scss">
.c-blue {
  color: #4090ff;
}
.work-box {
  margin-bottom: 0.6rem;
}
.work-item {
  color: rgba(0, 0, 0, 0.65);
  padding: 0.5rem 1rem;
  box-shadow: 0px 0px 5px 1px rgba(0, 0, 0, 0.1);
  align-items: center;
  cursor: pointer;
  &__num {
    font-weight: bold;
    font-size: 1.875rem;
    line-height: 3rem;
    color: rgba(0, 0, 0, 0.85);
  }
  &__icon {
    width: 3rem;
    height: 3rem;
    line-height: 3rem;
    text-align: center;
    border-radius: 50%;
    .dg-iconp {
      font-size: 1.5rem;
    }
  }
}
</style>
